/*
@author: stanfor
@date: 2022/8/19 14:58
@Version: 1.0
@last modify time : 2022/8/19 14:58
*/

import React, { FC, ReactElement } from 'react';
import { Input, InputProps, Col, Form } from 'antd';
import { getRulesConfig, commonInterface } from '@C/base/SFields/constant';
import './index.less';

interface IProps extends commonInterface{
  // 表单最大值，默认最大 32 位
  maxLength: string|number;
}

const Index: FC<Partial<IProps> & Omit<InputProps, 'type'>> = (props): ReactElement => {
  const { name, maxLength = 32, label = '标签', span = 8, required = false, ruleIcon, formItemConfig, ...inputProps } = props;

  return (
    <Col span={span}>
      <div className="base-component-super-fields-common">
        <Form.Item
          label={label}
          name={name}
          rules={getRulesConfig(required, label, ruleIcon)}
          {...formItemConfig}
        >
          <Input placeholder="请输入..." maxLength={maxLength} {...inputProps} />
        </Form.Item>
      </div>
    </Col>
  );
};

export default Index;
